package com.dailyblue.java.spring.boot.mvc.mybatis.mapper;

import com.dailyblue.java.spring.boot.commons.bean.Reply;
import com.dailyblue.java.spring.boot.commons.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.Set;

@Mapper
public interface ReplyMapper {
    @Select("select * from reply where postid=#{pid}")
    @Results({
            @Result(property = "id",column = "id",id = true),
            @Result(property = "user",column = "userId",javaType = User.class,
                    one = @One(select = "com.dailyblue.java.spring.boot.mvc.mybatis.mapper.UserMapper.findUserById"))
    })
    Set<Reply> findAllReplyByPostId(int pid);
    @Insert("insert into reply values(null,#{content},now(),#{userId},#{postId},1)")
    void saveReply(Reply reply);
}
